﻿using System;
using System.Collections.Generic;
using System.Web;
using Exam.Core;

/// <summary>
///StudentPageBase 的摘要说明
/// </summary>
public class StudentPageBase : System.Web.UI.Page {
    private int userId = 1;
    private bool isLogin = false;
    protected Exam.Core.Model.Student isTheMe;

    public StudentPageBase() {
        //
        //TODO: 在此处添加构造函数逻辑
        //
    }
    protected void ManagePage_Load(object sender, System.EventArgs e) {

    }
    protected void ManagePage_Error(object sender, System.EventArgs e) {
        Exception currentError = Server.GetLastError();
        //this.WriteException(currentError);
        //GotoErrorPage("", "您的操作出现了错误，错误原因：" + currentError.Message.ToString(), Request.RawUrl);
        //Server.ClearError();
    }
    protected override void OnInit(EventArgs e) {
        base.OnInit(e);
        this.Load += new System.EventHandler(this.ManagePage_Load);
        this.Error += new System.EventHandler(this.ManagePage_Error);
        CheckLogin();
        if (!isLogin) {
            //Response.Redirect("login.aspx");
            Response.Redirect(Utils.RelativeWebRoot + "login.aspx", true);
        }

    }
    private void CheckLogin() {
        //isTheMe = new Exam.Core.DAL.Student().getStudent(userId);
        string tmp = Cookie.GetCookie(ExamSys.cookies_name.Trim()).Trim();
        if (tmp != "") {
            string[] str = tmp.Split('|');
            isTheMe = new Exam.Core.Model.Student();
            isTheMe.StudentID = str[0].Trim();
            isTheMe.StudentNumber = str[1].Trim();
            isTheMe.StudentName = str[2].Trim();
            isTheMe.StudentPassword = str[3].Trim();
            isTheMe.StudentEmail = str[4].Trim();
            isTheMe.DepartmentID = str[5].Trim();
            isLogin = true;
        }


    }

}
